//编写程序，接受三个参数：一个输入文件和两个输出文件的文件名。输入文件保存的应该是整数。使用istream_iterator读取输入文件。
//使用ostream_iterator将奇数写入第一个输出文件，每个值之后都跟一个空格。将偶数写入第二个输出文件，每个值都独占一行。
#include<iostream>
#include<vector>
#include<list>
#include<algorithm>
#include<iterator>
#include<fstream>
#include<string>
using namespace std;
int main(int argc,char *argv[])
{
	if (argc!=4) {
		cout << "introduce:execise.exe in_file "
			"out_file1 out_file2"<< endl;
		return -1;
	}
	ifstream in(argv[1]);
	if (!in) {
		cout << "error to open file!" << endl;
		exit(1);
	}
	ofstream out1(argv[2]);
	if (!out1) {
		cout << "error to open file 1!" << endl;
		exit(1);
	}
	ofstream out2(argv[3]);
	if (!out2) {
		cout << "error to open file 2!" << endl;
		exit(1);
	}
	istream_iterator<int>in_iter(in);
	istream_iterator<int>eof;
	ostream_iterator<int>out_iter1(out1, " ");
	ostream_iterator<int>out_iter2(out2, "\n");
	while (in_iter != eof) {
		if (*in_iter & 1)
			*out_iter1++ = *in_iter;
		else *out_iter2++ = *in_iter;
		in_iter++;
	}
	system("pause");
	return 0;
}